package top.infopub.enums.mkt;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public enum StandardEnum {
	/**
	 * 1, "一般预算收入"
	 */
	YIBAN_SHOURU("1", "一般预算收入(亿元)"),
	/**
	 * 2, "建安占比"
	 */
	JIANAN_ZHANBI("2", "建安占比(%)"),
	/**
	 * 3, "总投资额"
	 */
	ZOUTOU_ZIE("3", "总投资额(万元)"),
	/**
	 * 4, "入库情况"
	 */
	RUKU_QINGKUANG("4", "入库情况"),
	/**
	 * 5, "建安工程费"
	 */
	JIANAN_GONGCHENGFEI("5", "建安工程费"),
	/**
	 * 6, "运营周期（年）"
	 */
	YUNYIN_GZHOUQI("6", "运营周期（年）"),
	/**
	 * 7, "建设周期（年）"
	 */
	JIANSHEN_ZHOUNIAN("7", "建设周期（年）"),
	/**
	 * 8, "合作周期（年）"
	 */
	HEZUO_ZHOUNIAN("8", "合作周期（年）"),
	/**
	 * 9, "资本金比例"
	 */
	ZIBENJIN_BILI("9", "资本金比例"),
	/**
	 * 10, "投资回报率"
	 */
	TOUZI_HUIBAOLV("10", "投资回报率"),
	/**
	 * 11, "融资回报率"
	 */
	RONGZI_HUIBAOLV("11", "融资回报率"),

	GET_JIANAN("12", "1.建安工程费用(万元)"),
	SHEBEI("13", "2.设备购置费用(万元)"),
	GONGCHENG("14", "3.工程建设其他(万元)"),
	YUBEI("15", "4.预备费(万元)"),
	JIANSHE("16", "5.建设期利息(万元)"),
	HEJI("17", "合计(万元)");

	private String code;

	private String baseLineName;

	StandardEnum(String code, String baseLineName) {
		this.code = code;
		this.baseLineName = baseLineName;
	}
	/** 获取枚举value **/
	public static String getValue(String type) {
		StandardEnum [] standardEnums = values();
        for (StandardEnum standardEnum : standardEnums) {
            if (standardEnum.getCode().equals(type)) {
                return standardEnum.getBaseLineName();
            }
        }
        return null;
    }

    /**
     *枚举全部转化成json
     * @return
     */
    public static String toJson(){
        JSONArray jsonArray = new JSONArray();
        for (StandardEnum e : StandardEnum.values()) {
            JSONObject object = new JSONObject();
            object.put("typeId", e.getCode());
            object.put("typeName", e.getBaseLineName());
            jsonArray.add(object);
        }
        return jsonArray.toString();
    }
    /**
     *枚举全部转化成jsonArray
     * @return
     */
    public static JSONArray toJsonArray(){
        JSONArray jsonArray = new JSONArray();
        for (StandardEnum e : StandardEnum.values()) {
            JSONObject object = new JSONObject();
            object.put("typeId", e.getCode());
            object.put("typeName", e.getBaseLineName());
            jsonArray.add(object);
        }
        return jsonArray;
    }

	public String getCode() {
		return this.code;
	}

	public String getBaseLineName() {
		return baseLineName;
	}

}
